package com.shengde.jinwawaforleader.model.myJob.classStatus;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.shengde.jinwawaforleader.R;
import com.shengde.jinwawaforleader.base.BaseActivity;
import com.shengde.jinwawaforleader.base.CommonBaseAdapter;
import com.shengde.jinwawaforleader.base.ViewHolder;
import com.shengde.jinwawaforleader.bean.User;
import com.shengde.jinwawaforleader.model.myJob.adapter.ImageGridAdapter;
import com.shengde.jinwawaforleader.network.BaseProtocol;
import com.shengde.jinwawaforleader.network.protocolbean.ProShowClickGood;
import com.shengde.jinwawaforleader.network.protocolbean.ProShowClickGoodCancle;
import com.shengde.jinwawaforleader.network.protocolbean.ProShowCommentList;
import com.shengde.jinwawaforleader.network.protocolbean.ProShowCommentVideoList;
import com.shengde.jinwawaforleader.network.protocolbean.ProVideoShowClickGood;
import com.shengde.jinwawaforleader.network.protocolbean.ProVideoShowClickGoodCancle;
import com.shengde.jinwawaforleader.utils.DateUtil;
import com.shengde.jinwawaforleader.utils.UmengShareUtil;
import com.shengde.jinwawaforleader.views.CircleImageView;
import com.umeng.socialize.UMShareAPI;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

import static com.shengde.jinwawaforleader.HomeApplication.showToastShort;

/**
 * 班级动态详情页面
 * Created by Administrator on 2016/11/23 0023.
 */
public class ClassStatusItemDetailActivity extends BaseActivity implements AdapterView.OnItemClickListener {
	private static final String TAG = "ClassStatusItemDetailAc";
	private static final int FINSH = 1;
	private static final int COMMENT_SUCCESS = 2;
	private static final int FINSH_VIDEO = 3;
	private TextView tv_title; //title name
	private TextView tv_back;  //返回
	private EditText edt_comment;  //评论框
	private Button btn_send;   //发送按钮
	//	private ListView lv_detail; //listview
	private CircleImageView imgHead;  //头像
	private ImageView iv_video_pic;  //视频第一帧图片
	private ImageView iv_small_class_video;  //是视频的时候
	private ImageView iv_class_album;  //是相册的时候
	private ImageView iv_video_share;  //视频分享
	private JCVideoPlayerStandard imb_video_play;  //视频的播放按钮
	private TextView tvName;  //姓名
	private TextView tvContent;  //内容
	private TextView tvDate; //日期
	private GridView gridview_pic;  //图片布局
	private ImageView ivAgree; //点赞图片
	private TextView tvAgree; //点赞数量
	private TextView tvComment;  //评论数量
	private TextView tv_look_people;  //看过的人是数量
	private ImageView ivComment;  //评论图片
	private RelativeLayout relative_video_item;  //视频include 布局

	private String tv_name;
	private String tv_detail;
	private String img_url;
	private String iv_logo;
	private String mv_url;
	private int tv_comment_num;
	private int tv_good;
	private int iscount;
	private int look_people_num;
	private int joinid;
	private int curpage = 1;
	private int mTotalpage;

	private Long last_time;
	private ArrayList<String> img_list;
	private ArrayList<String> id_list;
	private List<ProShowCommentList.CommentsBean> commentsBeanList;
	private ArrayList<ProShowCommentList.CommentsBean> commentsBeanLists = new ArrayList();
	private List<ProShowCommentVideoList.CommentsBean> commentvideoBeanList;
	private ArrayList<ProShowCommentVideoList.CommentsBean> commentsVideoBeanLists = new ArrayList();
	private CommonBaseAdapter mCommonBaseAdapter;
	private CommonBaseAdapter mCommonVideoBaseAdapter;
	private PullToRefreshListView pull_refresh_list; //下拉刷新 和上拉加载跟多
	private ListView lv_detail;   //下拉刷新的listview

	private Handler mHandler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			switch (msg.what) {
				case FINSH:
					Log.i(TAG, "handleMessage: beanSize_0 = " + commentsBeanList.size());
					Log.i(TAG, "handleMessage: beanSize_2 = " + commentsBeanLists.size());
					pull_refresh_list.onRefreshComplete();
					if (mCommonBaseAdapter == null) {
						mCommonBaseAdapter = new CommonBaseAdapter(ClassStatusItemDetailActivity.this, commentsBeanLists, R.layout.class_status_item) {
							@Override
							public void convert(ViewHolder holder, int position) {
								holder.setText(R.id.tv_name, commentsBeanLists.get(position).getName());
								holder.setText(R.id.tv_time, DateUtil.getDate(String.valueOf(commentsBeanLists.get(position).getLasttime())));
								// 发布的内容 转换成utf-8
								String emocontent = "";
								try {
									emocontent = URLDecoder.decode(commentsBeanLists.get(position).getContent(), "UTF-8");
								} catch (Exception e) {
									// TODO: handle exception
								}
								holder.setText(R.id.tv_comment, emocontent);
								Glide.with(ClassStatusItemDetailActivity.this).load(BaseProtocol.IMG_BASE + commentsBeanLists.get(position).getLogo())
										.error(R.drawable.touxiang).into((ImageView) holder.getView(R.id.iv_circle_pic));
							}
						};
						lv_detail.setAdapter(mCommonBaseAdapter);
					} else {
						mCommonBaseAdapter.notifyDataSetChanged();
					}
					break;
				case FINSH_VIDEO:
					pull_refresh_list.onRefreshComplete();
					if (mCommonVideoBaseAdapter == null) {
						mCommonVideoBaseAdapter = new CommonBaseAdapter(ClassStatusItemDetailActivity.this, commentsVideoBeanLists, R.layout.class_status_item) {
							@Override
							public void convert(ViewHolder holder, int position) {
								holder.setText(R.id.tv_name, commentsVideoBeanLists.get(position).getName());
								holder.setText(R.id.tv_time, DateUtil.getDate(String.valueOf(commentsVideoBeanLists.get(position).getLasttime())));
								// 发布的内容 转换成utf-8
								String emocontent = "";
								try {
									emocontent = URLDecoder.decode(commentsVideoBeanLists.get(position).getContent(), "UTF-8");
								} catch (Exception e) {
									// TODO: handle exception
								}
								holder.setText(R.id.tv_comment, emocontent);
								Glide.with(ClassStatusItemDetailActivity.this).load(BaseProtocol.IMG_BASE + commentsVideoBeanLists.get(position).getLogo())
										.error(R.drawable.touxiang)
										.into((ImageView) holder.getView(R.id.iv_circle_pic));
							}
						};
						lv_detail.setAdapter(mCommonVideoBaseAdapter);
					} else {
						Log.i(TAG, "handleMessage: adapter_size = "+ mCommonVideoBaseAdapter.getCount());
						Log.i(TAG, "handleMessage: size = "+commentsVideoBeanLists.size());
						mCommonVideoBaseAdapter.notifyDataSetChanged();
					}
					break;
				case COMMENT_SUCCESS:
					edt_comment.setText("");
					tv_comment_num++;
					tvComment.setText(tv_comment_num + "");
					break;

			}
		}
	};

	@Override
	public void onRoot(Bundle savedInstanceState) {
		setContentView(R.layout.class_status_item_detail_activity);

	}

	@Override
	public void initView() {
		tv_name = getIntent().getStringExtra("tv_name");
		tv_comment_num = getIntent().getIntExtra("tv_comment_num", 0);
		tv_detail = getIntent().getStringExtra("tv_detail");
		tv_good = getIntent().getIntExtra("tv_good", 0);
		img_url = getIntent().getStringExtra("img_url");
		iscount = getIntent().getIntExtra("iscount", 0);
		look_people_num = getIntent().getIntExtra("tv_look_people", 0);
		joinid = getIntent().getIntExtra("joinid", 0);
		iv_logo = getIntent().getStringExtra("iv_logo");
		mv_url = getIntent().getStringExtra("mv_url");
		last_time = getIntent().getLongExtra("last_time", 0);
		img_list = getIntent().getStringArrayListExtra("img_list");
		id_list = getIntent().getStringArrayListExtra("id_list");
		pull_refresh_list = (PullToRefreshListView) findViewById(R.id.lv_detail);
		lv_detail = pull_refresh_list.getRefreshableView();
		View headView = getLayoutInflater().inflate(R.layout.class_status_antivity_item, null);

		tv_back = (TextView) findViewById(R.id.tv_back);
		tv_title = (TextView) findViewById(R.id.tv_title);

		edt_comment = (EditText) findViewById(R.id.edt_comment);
		btn_send = (Button) findViewById(R.id.btn_send);
		lv_detail.addHeaderView(headView);
		imgHead = (CircleImageView) headView.findViewById(R.id.imgHead);
		iv_video_pic = (ImageView) headView.findViewById(R.id.iv_video_pic);
		iv_small_class_video = (ImageView) headView.findViewById(R.id.iv_small_class_video);
		iv_class_album = (ImageView) headView.findViewById(R.id.iv_class_album);
		iv_video_share = (ImageView) headView.findViewById(R.id.iv_video_share);
		imb_video_play = (JCVideoPlayerStandard) headView.findViewById(R.id.imb_video_play);
		tvName = (TextView) headView.findViewById(R.id.tvName);
		tvContent = (TextView) headView.findViewById(R.id.tvContent);
		tvDate = (TextView) headView.findViewById(R.id.tvDate);
		gridview_pic = (GridView) headView.findViewById(R.id.gridview_pic);
		ivAgree = (ImageView) headView.findViewById(R.id.ivAgree);
		tvAgree = (TextView) headView.findViewById(R.id.tvAgree);
		tvComment = (TextView) headView.findViewById(R.id.tvComment);
		tv_look_people = (TextView) headView.findViewById(R.id.tv_look_people);
		ivComment = (ImageView) headView.findViewById(R.id.ivComment);
		relative_video_item = (RelativeLayout) headView.findViewById(R.id.relative_video_item);

	}

	@Override
	public void initData() {
		tv_title.setText(getString(R.string.detail));
		tvName.setText(tv_name);
		tvAgree.setText(tv_good + "");
		tvComment.setText(tv_comment_num + "");
		tv_look_people.setText(look_people_num+"");
		//头像的设置
		if ("".equals(iv_logo) || iv_logo == null) {
			imgHead.setImageResource(R.drawable.touxiang);
		} else {
			Glide.with(this)
					.load(BaseProtocol.IMG_BASE + iv_logo)
					.error(R.drawable.touxiang)
					.into(imgHead);
		}
		if (iscount == 0) {
			ivAgree.setImageResource(R.drawable.zan);
		} else {
			ivAgree.setImageResource(R.drawable.iszan);
		}
		ivAgree.setFocusable(false);
		// 发布的内容 转换成utf-8
		String emocontent = "";
		try {
			emocontent = URLDecoder.decode(tv_detail, "UTF-8");
		} catch (Exception e) {
			// TODO: handle exception
		}
		tvContent.setText(emocontent);
		//发布的时间  (解析时间戳)
		tvDate.setText(DateUtil.getDate(String.valueOf(last_time)));

		if ("1".equals(mv_url)) {
			showAlbumCommentList(curpage);
			relative_video_item.setVisibility(View.GONE);
			gridview_pic.setVisibility(View.VISIBLE);
			iv_class_album.setVisibility(View.VISIBLE);
			iv_small_class_video.setVisibility(View.GONE);
			ImageGridAdapter gridAdapter = new ImageGridAdapter(ClassStatusItemDetailActivity.this,img_list);
			gridview_pic.setAdapter(gridAdapter);
		} else {
			showVideoCommentList(curpage);
			relative_video_item.setVisibility(View.VISIBLE);
			iv_small_class_video.setVisibility(View.VISIBLE);
			iv_class_album.setVisibility(View.GONE);
			gridview_pic.setVisibility(View.GONE);
			if ("".equals(img_url)) {
				imb_video_play.ivThumb.setImageResource(R.drawable.video_bg);
			} else {
				Glide.with(this)
						.load(BaseProtocol.IMG_FRIST_BASE + img_url)
						.error(R.drawable.video_bg)
						.into(imb_video_play.ivThumb);
			}
			imb_video_play.setUp(BaseProtocol.VIDEO_BASE + mv_url,"");

		}
	}
	@Override
	public void initListener() {
		tv_back.setOnClickListener(this);
		tv_look_people.setOnClickListener(this);
		gridview_pic.setOnItemClickListener(this);
		ivAgree.setOnClickListener(this);
		iv_video_share.setOnClickListener(this);
		btn_send.setOnClickListener(this);
		//刷新监听
		pull_refresh_list.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
			@Override
			public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
				if ("1".equals(mv_url)) {
					curpage = 1;
					showAlbumCommentList(curpage);
					showToastShort(getString(R.string.refresh_success));
				} else {
					curpage = 1;
					showVideoCommentList(curpage);
					showToastShort(getString(R.string.refresh_success));


				}
			}

			@Override
			public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
				if ("1".equals(mv_url)) {
					curpage++;
					if (curpage> mTotalpage) {
						curpage--;
						pull_refresh_list.onRefreshComplete();
						showToastShort(getString(R.string.xlistview_footer_no_more_msg));
					} else {
						Log.i(TAG, "onPullUpToRefresh: curpage = " + curpage);
						showAlbumCommentList(curpage);
						showToastShort(getString(R.string.loading_success));
					}
				} else {
					curpage++;
					if (curpage> mTotalpage) {
						curpage--;
						pull_refresh_list.onRefreshComplete();
						showToastShort(getString(R.string.xlistview_footer_no_more_msg));
					} else {
						Log.i(TAG, "onPullUpToRefresh: curpage = " + curpage);
						showVideoCommentList(curpage);
						showToastShort(getString(R.string.loading_success));
					}
				}
			}
		});


	}

	@Override
	public void onWidgetClick(View view) {
		switch (view.getId()) {
			case R.id.tv_back:
				finish();
				break;
			case R.id.imb_video_play:  //播放视频
				Intent intent = new Intent(Intent.ACTION_VIEW);
				intent.setDataAndType(Uri.parse(BaseProtocol.VIDEO_BASE + mv_url), "video/mp4");
				startActivity(intent);
				break;
			case R.id.ivAgree:
				if ("1".equals(mv_url)) {
					if (iscount == 0) {
						showClickGood(joinid);
						ivAgree.setImageResource(R.drawable.iszan);
						tv_good++;
						tvAgree.setText(tv_good + "");
						iscount = 1;
					} else {
						showClickGoodCancle(joinid);
						ivAgree.setImageResource(R.drawable.zan);
						tv_good--;
						tvAgree.setText(tv_good + "");
						iscount = 0;
					}
				} else {
					if (iscount == 0) {
						showVideoClickGood(joinid);
						ivAgree.setImageResource(R.drawable.iszan);
						tv_good++;
						tvAgree.setText(tv_good + "");
						iscount = 1;
					} else {
						showVideoClickGoodCancle(joinid);
						ivAgree.setImageResource(R.drawable.zan);
						tv_good--;
						tvAgree.setText(tv_good + "");
						iscount = 0;
					}

				}
				break;
			case R.id.iv_video_share:
				if ("1".equals(mv_url)) {

					final String targeturl = BaseProtocol.IMG_SHARE
							+ joinid;
					String imglist_content = "";
					try {
						imglist_content = URLDecoder.decode(tv_detail, "utf-8");
					} catch (UnsupportedEncodingException e) {
						e.printStackTrace();
					}
					if (TextUtils.isEmpty(imglist_content)) {
						imglist_content = "班级相册";
					}
					String url = BaseProtocol.IMG_BASE
							+ img_list.get(0);
					UmengShareUtil.shareUrl(this, "班级相册", imglist_content, url, targeturl);

				} else {
					//					Bitmap bitmap;
					final String targeturl = BaseProtocol.VIDEO_SHARE
							+ joinid;
					final String url = BaseProtocol.IMG_FRIST_BASE
							+ mv_url;
					String imglist_content = "";
					try {
						imglist_content = URLDecoder.decode(tv_detail, "utf-8");
					} catch (UnsupportedEncodingException e) {
						e.printStackTrace();
					}
					if (TextUtils.isEmpty(imglist_content)) {
						imglist_content = "班级视频";
					}
					UmengShareUtil.shareUrl(this, "班级视频", imglist_content, url, targeturl);
				}
				break;
			case R.id.btn_send:
				if ("1".equals(mv_url)) {
					showSendAlbumComment();
				} else {
					showSendVideoComment();
				}
				break;
			case R.id.tv_look_people:
				intent = new Intent(this,LookPeopleNumActivity.class);
				intent.putExtra("joinid", joinid);
				startActivity(intent);
				break;
		}

	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		Intent intent = new Intent(ClassStatusItemDetailActivity.this,
				AlbumImageBrowserActivity.class);
		intent.putExtra("pos", position);
		intent.putStringArrayListExtra("list", img_list);
		startActivity(intent);

	}
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);

	}


	/**
	 * 发送视频评论
	 */
	private void showSendVideoComment() {

		Log.i(TAG, "showSendVideoComment: 123456789");
		final String content = edt_comment.getText().toString().trim();

		String emocontent = "";
		try {
			emocontent = URLEncoder.encode(content, "UTF-8");
		} catch (Exception e) {
			// TODO: handle exception
		}

		if (TextUtils.isEmpty(content)) {
			Toast.makeText(this, "评论不能为空！", Toast.LENGTH_SHORT).show();
			return;
		}
		String url = "";
		if (User.isTest) {
			url = BaseProtocol.HOST_BASE_TEST + "/mv/MvCommentPublish";
		} else {
			url = BaseProtocol.HOST_BASE + "/mv/MvCommentPublish";
		}
		RequestParams params = BaseProtocol.getRequestParams(url);
		params.addParameter("mvid", joinid);
		params.addParameter("userid", User.getUserLoginAccount(this));
		params.addParameter("content", emocontent);
		x.http().post(params, new Callback.CommonCallback<String>() {
			@Override
			public void onSuccess(String result) {
				ProShowClickGood proShowClickGood = new Gson().fromJson(result, ProShowClickGood.class);
				if (proShowClickGood.getCode() == 0) {
					Log.i(TAG, "onSuccess: 评论成功");
					Toast.makeText(ClassStatusItemDetailActivity.this, "评论成功", Toast.LENGTH_SHORT).show();
					mHandler.sendEmptyMessage(COMMENT_SUCCESS);
					curpage = 1;
					showVideoCommentList(curpage);

				}

			}

			@Override
			public void onError(Throwable ex, boolean isOnCallback) {
				Toast.makeText(ClassStatusItemDetailActivity.this, "评论失败,请检查你的网络", Toast.LENGTH_SHORT).show();

			}

			@Override
			public void onCancelled(CancelledException cex) {

			}

			@Override
			public void onFinished() {

			}
		});
	}

	/**
	 * 发送相册评论
	 */
	private void showSendAlbumComment() {

		final String content = edt_comment.getText().toString().trim();

		String emocontent = "";
		try {
			emocontent = URLEncoder.encode(content, "UTF-8");
		} catch (Exception e) {
			// TODO: handle exception
		}

		if (TextUtils.isEmpty(content)) {
			Toast.makeText(this, "评论不能为空！", Toast.LENGTH_SHORT).show();
			return;
		}
		String url = "";
		if (User.isTest) {
			url = BaseProtocol.HOST_BASE_TEST + "/teacher/AlbumCommentPublish";
		} else {
			url = BaseProtocol.HOST_BASE + "/teacher/AlbumCommentPublish";
		}
		RequestParams params = BaseProtocol.getRequestParams(url);
		params.addParameter("albumid", joinid);
		params.addParameter("userid", User.getUserLoginAccount(this));
		params.addParameter("content", emocontent);
		x.http().post(params, new Callback.CommonCallback<String>() {
			@Override
			public void onSuccess(String result) {
				ProShowClickGood proShowClickGood = new Gson().fromJson(result, ProShowClickGood.class);
				if (proShowClickGood.getCode() == 0) {
					Log.i(TAG, "onSuccess: 评论成功");
					Toast.makeText(ClassStatusItemDetailActivity.this, "评论成功", Toast.LENGTH_SHORT).show();
					mHandler.sendEmptyMessage(COMMENT_SUCCESS);
					curpage = 1;
					showAlbumCommentList(curpage);

				}

			}

			@Override
			public void onError(Throwable ex, boolean isOnCallback) {
				Toast.makeText(ClassStatusItemDetailActivity.this, "评论失败,请检查你的网络", Toast.LENGTH_SHORT).show();

			}

			@Override
			public void onCancelled(CancelledException cex) {

			}

			@Override
			public void onFinished() {

			}
		});
	}

	/**
	 * 获取视频评论列表
	 *
	 * @param curpage
	 */
	private void showVideoCommentList(final int curpage) {
		String url = "";
		if (User.isTest) {
			url = BaseProtocol.HOST_BASE_TEST + "/mv/MvCommentList";
		} else {
			url = BaseProtocol.HOST_BASE + "/mv/MvCommentList";
		}
		RequestParams params = BaseProtocol.getRequestParams(url);
		params.addParameter("mvid", joinid);
		params.addParameter("curpage", curpage);
		x.http().post(params, new Callback.CommonCallback<String>() {
			@Override
			public void onSuccess(String result) {
				ProShowCommentVideoList proShowCommentVideoList = new Gson().fromJson(result, ProShowCommentVideoList.class);
				if (proShowCommentVideoList.getCode() == 0) {
					mTotalpage = proShowCommentVideoList.getTotalpages();
					if (curpage == 1) {
						commentsVideoBeanLists.clear();
					}

					Log.i(TAG, "onPullUpToRefresh: getTotalpages = " +proShowCommentVideoList.getTotalpages());

					commentvideoBeanList = proShowCommentVideoList.getComments();
					for (int i = 0; i < commentvideoBeanList.size(); i++) {
						commentsVideoBeanLists.add(commentvideoBeanList.get(i));
					}
					mHandler.sendEmptyMessage(FINSH_VIDEO);
				}

			}

			@Override
			public void onError(Throwable ex, boolean isOnCallback) {

			}

			@Override
			public void onCancelled(CancelledException cex) {

			}

			@Override
			public void onFinished() {

			}
		});
	}

	/**
	 * 获取相册评论列表
	 *
	 * @param curpage
	 */
	private void showAlbumCommentList(final int curpage) {
		String url = "";
		if (User.isTest) {
			url = BaseProtocol.HOST_BASE_TEST + "/teacher/AlbumCommentList";
		} else {
			url = BaseProtocol.HOST_BASE + "/teacher/AlbumCommentList";
		}
		RequestParams params = BaseProtocol.getRequestParams(url);
		params.addParameter("albumid", joinid);
		params.addParameter("curpage", curpage);
		x.http().post(params, new Callback.CommonCallback<String>() {
			@Override
			public void onSuccess(String result) {
				ProShowCommentList proShowCommentList = new Gson().fromJson(result, ProShowCommentList.class);
				if (proShowCommentList.getCode() == 0) {
					mTotalpage = proShowCommentList.getTotalpages();
					if (curpage == 1) {
						commentsBeanLists.clear();
					}
					commentsBeanList = proShowCommentList.getComments();
					for (int i = 0; i < commentsBeanList.size(); i++) {
						commentsBeanLists.add(commentsBeanList.get(i));
					}
					mHandler.sendEmptyMessage(FINSH);
				}

			}

			@Override
			public void onError(Throwable ex, boolean isOnCallback) {

			}

			@Override
			public void onCancelled(CancelledException cex) {

			}

			@Override
			public void onFinished() {

			}
		});
	}

	/**
	 * 相册点赞的网络请求
	 *
	 * @param joinid
	 */
	private void showClickGood(int joinid) {
		String url = "";
		if (User.isTest) {
			url = BaseProtocol.HOST_BASE_TEST + "/teacher/AlbumLook";
		} else {
			url = BaseProtocol.HOST_BASE + "/teacher/AlbumLook";
		}
		RequestParams params = BaseProtocol.getRequestParams(url);
		params.addParameter("albumid", joinid);
		params.addParameter("type", 2);
		params.addParameter("userid", User.getUserLoginAccount(this));
		x.http().post(params, new Callback.CommonCallback<String>() {
			@Override
			public void onSuccess(String result) {
				ProShowClickGood proShowClickGood = new Gson().fromJson(result, ProShowClickGood.class);
				if (proShowClickGood.getCode() == 0) {
					Log.i(TAG, "onSuccess: 点赞成功");

				}

			}

			@Override
			public void onError(Throwable ex, boolean isOnCallback) {

			}

			@Override
			public void onCancelled(CancelledException cex) {

			}

			@Override
			public void onFinished() {

			}
		});
	}

	/**
	 * 相册取消点赞的网络请求
	 *
	 * @param joinid
	 */
	private void showClickGoodCancle(int joinid) {
		String url = "";
		if (User.isTest) {
			url = BaseProtocol.HOST_BASE_TEST + "/teacher/AlbumCancel";
		} else {
			url = BaseProtocol.HOST_BASE + "/teacher/AlbumCancel";
		}
		RequestParams params = BaseProtocol.getRequestParams(url);
		params.addParameter("albumid", joinid);
		params.addParameter("userid", User.getUserLoginAccount(this));
		x.http().post(params, new Callback.CommonCallback<String>() {
			@Override
			public void onSuccess(String result) {
				ProShowClickGoodCancle proShowClickGoodCancle = new Gson().fromJson(result, ProShowClickGoodCancle.class);
				if (proShowClickGoodCancle.getCode() == 0) {
					Log.i(TAG, "onSuccess: 取消点赞成功");

				}

			}

			@Override
			public void onError(Throwable ex, boolean isOnCallback) {

			}

			@Override
			public void onCancelled(CancelledException cex) {

			}

			@Override
			public void onFinished() {

			}
		});
	}

	/**
	 * 视频点赞的网络请求
	 *
	 * @param joinid
	 */
	private void showVideoClickGood(int joinid) {
		String url = "";
		if (User.isTest) {
			url = BaseProtocol.HOST_BASE_TEST + "/mv/MvLook";
		} else {
			url = BaseProtocol.HOST_BASE + "/mv/MvLook";
		}
		//http://120.76.155.123:8080/api/mv/MvLook?userid=&mvid=
		RequestParams params = BaseProtocol.getRequestParams(url);
		params.addParameter("mvid", joinid);
		params.addParameter("userid", User.getUserLoginAccount(this));
		Log.i(TAG, "showVideoClickGood: joinid" + joinid);
		Log.i(TAG, "showVideoClickGood: USEid" + User.getUserLoginAccount(this));
		x.http().post(params, new Callback.CommonCallback<String>() {
			@Override
			public void onSuccess(String result) {
				ProVideoShowClickGood proShowClickGood = new Gson().fromJson(result, ProVideoShowClickGood.class);
				if (proShowClickGood.getCode() == 0) {
					Log.i(TAG, "onSuccess: 视频点赞成功");

				}
			}

			@Override
			public void onError(Throwable ex, boolean isOnCallback) {

			}

			@Override
			public void onCancelled(CancelledException cex) {

			}

			@Override
			public void onFinished() {

			}
		});
	}

	/**
	 * 视频取消点赞的网络请求
	 *
	 * @param joinid
	 */
	private void showVideoClickGoodCancle(int joinid) {
		String url = "";
		if (User.isTest) {
			url = BaseProtocol.HOST_BASE_TEST + "/mv/MvCancel";
		} else {
			url = BaseProtocol.HOST_BASE + "/mv/MvCancel";
		}
		RequestParams params = BaseProtocol.getRequestParams(url);
		params.addParameter("mvid", joinid);
		params.addParameter("userid", User.getUserLoginAccount(this));
		x.http().post(params, new Callback.CommonCallback<String>() {
			@Override
			public void onSuccess(String result) {
				ProVideoShowClickGoodCancle proVideoShowClickGoodCancle = new Gson().fromJson(result, ProVideoShowClickGoodCancle.class);
				if (proVideoShowClickGoodCancle.getCode() == 0) {
					Log.i(TAG, "onSuccess: 视频取消点赞成功");
				}

			}

			@Override
			public void onError(Throwable ex, boolean isOnCallback) {

			}

			@Override
			public void onCancelled(CancelledException cex) {

			}

			@Override
			public void onFinished() {

			}
		});
	}
}
